/*
 * @Author       : Zhaoyu.Wu
 * @Date         : 2021-10-09 16:53
 * @LastEditTime : 2021-10-14 15:22
 * @LastEditors  : Zhaoyu.Wu
 * @Description  : 
 * @FilePath     : /application/aes/aes.h
 * If you have any questions, email to zhaoyu.wu@diehl.com.
 */
#ifndef __AES_H__
#define __AES_H__

/******************************************************************************
 * Include files
 ******************************************************************************/
#include "aes_config.h"

/* C binding of definitions if building with C++ compiler */
#ifdef __cplusplus
extern "C"
{
#endif


/******************************************************************************
 * Global type definitions
 ******************************************************************************/

typedef enum en_aes_enable_mode
{
    AesMode_Encrypt = 0u,					///< AES encrypt
    AesMode_Decrypt = 1u,					///< AES decrypt				
}en_aes_enable_mode_t;

typedef enum en_aes_key_type
{
    AesKeyLen_128 = 0u,						///< 128 bits
    AesKeyLen_192 = 1u,						///< 192 bits
    AesKeyLen_256 = 2u,						///< 256 bits
}en_aes_key_len_t;

typedef enum en_aes_cpo_type
{
#if defined(CRYPTO_TYPE_AES_ECB)
	AesCpoType_Ecb = 0u, ///< AES ECB encryption type
#endif
#if defined(CRYPTO_TYPE_AES_CBC)
	AesCpoType_Cbc = 1u, ///< AES CBC encryption type
#endif
#if defined(CRYPTO_TYPE_AES_CFB)
	AesCpoType_Cfb = 2u, ///< AES CFB encryption type
#endif
#if defined(CRYPTO_TYPE_AES_CTR)
	AesCpoType_Ctr = 3u, ///< AES CTR encryption	type
#endif
#if defined(CRYPTO_TYPE_AES_OFB)
	AesCpoType_Ofb = 4u, ///< AES OFB encryption type
#endif
} en_aes_cpo_type_t;

typedef struct
{
    unsigned		char*	pu8InputByte;		///< AES 密文指针
    unsigned		char*	pu8OutputByte;		///< AES 明文指针
    unsigned		char*	pu8Key;				///< AES 密钥指针
#if defined (CRYPTO_TYPE_AES_CBC)
	unsigned		char*	pu8Ivec;			///< AES 初始化向量
#endif
	//TODO: padding mode: None, PKCS7, Zero, ISO10126, Ansix923
	unsigned		char	u8Padding;			///< AES 加密时数据长度不足时填充的数据
	unsigned		int		u32ByteDataNum;		///< AES 待操作数据长度，以8位数据计算
    en_aes_key_len_t	   	enKeyLen;			///< AES 密钥长度类型
	en_aes_cpo_type_t		enCpoType;			///< AES 数据加密类型
	en_aes_enable_mode_t	enMode;				///< AES 加密或解密运算选择
}stc_aes_cfg_t;

char aes_crypt(stc_aes_cfg_t* pstcAesCfg);

char _basic_aes_encrypt(stc_aes_cfg_t *ctx);
char _basic_aes_decrypt(stc_aes_cfg_t *ctx);

#ifdef __cplusplus
}
#endif

#endif /* __AES_H__ */

